package com.huawei.orderservice.listeners;


import com.huawei.orderservice.service.OrderService;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PayStatusListener {
    @Autowired
    private OrderService orderService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "douyue.order.cancle.queue", durable = "true"),
            exchange = @Exchange(name = "douyue.topic", type = "topic"),
            key = "pay.success"
    ))
    public void OrderPaySuccess(Long orderId){
        //修改订单状态
        System.out.println("**************" + orderId);
        orderService.cancelOrder(orderId);
    }
}
